#ifndef MODEL_H
#define MODEL_H

#include <QObject>
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QProcess>
#include "json/json.h"
#include "htbengine.h"

using namespace Json;



class Model : public QObject
{
	Q_OBJECT

	public:
		Model();
		void init();
		Value *getSettings();
		void writeSettings(Value settings);
		int addRule(Value rule);
		Value getRules();
		int delRule(int ruleID);
		int editRule(Value rule,int ruleID);
		void stop();
		QMap <QString,QString> getRates();
		static int addStrToFile(QString str,QString filename);
		static  QString getSettingsDir();
		static int truncateFile(QString filename);
	private:
		QProcess *execCmd;
		int executeTcrules();
		TcEngine *tcEngine;
		Value settings;
		void writeJsonValueToFile(QString filename,Value jsonValue);
		Value getJsonValueFromFile(QString fileName);
};

#endif
